using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public class GunFire : MonoBehaviour
{
    private Light2D Gunlight;
    private float durationTimer;
    [SerializeField] private VisionSetting fireLight;
    [SerializeField] private VisionSetting defalutLight;
    // Start is called before the first frame update
    private void Awake()
    {
        Gunlight = GetComponent<Light2D>();
    }
    private void OnEnable()
    {
        durationTimer = fireLight.holdTime+fireLight.gradientTime;
        LightManager.Instance.ApplyLightParameters(Gunlight, fireLight);
        LightManager.Instance.GiveVision(Gunlight,fireLight,defalutLight,fireLight.holdTime,fireLight.gradientTime);

    }
    void Update()
    {
        durationTimer -= Time.deltaTime;
        if (durationTimer <= 0)
        {
            
            Extinguish();
        }
    }
    // Update is called once per frame
    private void Extinguish()
    {
            ObjectPool.Instance.PushObject(gameObject);
    }
}
